(function ($, w, undefined) {
  if (w.footable === undefined || w.foobox === null)
    throw new Error('Please check and make sure footable.js is included in the page and is loaded prior to this script.');
  var defaults = {};
  function SortName() {
    var p = this;
    p.name = 'Footable MyPlugin';
    p.init = function(ft) {
		p.footable = ft;
		if (ft.options.sort === true) {
			$(ft.table).bind({
			   'footable_column_data.sorting': function (e) {
					var $th = $(e.column.th);
					e.column.data.sort = e.column.data.sort || {};
					e.column.data.sort.name = $th.data('sort-name') || $th.data('name') || $.trim($th.text());
				}
			});
		}		
    };
  }  
  w.footable.plugins.register(SortName, defaults);  
})(jQuery, window);